package guinhanUDP;

import java.io.FileInputStream;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class clientguiUDP {
	public static void main(String[] args) throws IOException{
		DatagramSocket clientSK;
		DatagramPacket clientPK;
		byte[]data=new byte[1024];
		clientSK=new DatagramSocket();
		FileInputStream input=new FileInputStream("C:/filegui.rar");
		while(true)
		{
			if(input.read(data)!=-1){
				clientPK=new DatagramPacket(data, data.length, InetAddress.getLocalHost(), 7777);
				clientSK.send(clientPK);
			}
			else{
				clientPK=new DatagramPacket("exit".getBytes(),"exit".getBytes().length, InetAddress.getLocalHost(), 7777 );
				clientSK.send(clientPK);
				break;
			}
		}
		clientSK.close();input.close();
		System.out.println("gui thanh cong...");
	}
}
